/**
 * @Author:高志斐
 * @Date:2020/7/3
 * @Description:这是钱包页面
 */
import React,{Component} from "react";
import {Button, Icon, NavBar, WhiteSpace} from "antd-mobile";
import axios from "axios";
import {URL} from "../../index";
import {getCookieId} from "../Login/Component_Login/GetCookie";

export default class RetestRisk extends Component{
    constructor(props) {
        super(props);
        this.state = {
            accountAmount:0
        };
        this.handleLeftClick=this.handleLeftClick.bind(this)
    }
    componentDidMount() {
        this.loadAccountAmount()
    }
    handleClick(){
        this.props.history.push("/riskEval")
    }
    //设置缓存并返回到我的页
    handleLeftClick(event){
        localStorage.setItem('tabs',2);
        this.props.history.push('/terran/my')
    }
    //加载账户余额
    loadAccountAmount(){
        axios({
            method:"GET",
            url: URL + "/userInfo/getAccountAmoount",
            params: {
                userId:getCookieId()
            }
        }).then(res => {
            if (res.data.code === 200) {
                this.setState({
                    accountAmount: res.data.userAccountAmoount
                })
            }else{
                console.log(res.data.code)
            }
        })
    }
    render() {
        return(
            <div>
                {/*顶部导航栏*/}
                <NavBar
                    mode="light"
                    icon={<Icon type="left" style={{color:"#f8a83f"}}/>}
                    onLeftClick={this.handleLeftClick}
                >我的钱包</NavBar>
                <WhiteSpace />
                <WhiteSpace />
                <WhiteSpace />
                <WhiteSpace />
                <WhiteSpace />
                <div className='wallet-img'>
                    <img
                        src={[require("../../access/images/钱包.png")]}
                        style={{width:'80px',height:'80px'}}
                        alt=''
                    />
                </div>
                <WhiteSpace />
                <WhiteSpace />
                <WhiteSpace />
                <div className='wallet-num-container'>
                    <span style={{fontSize:"16px"}}>我的余额</span>
                    <WhiteSpace />
                    <strong><span style={{fontSize:"38px"}}>￥{this.state.accountAmount}</span></strong>
                    <WhiteSpace />
                    <WhiteSpace />
                    <WhiteSpace />
                    <Button
                        type="primary" inline style={{ marginRight: '4px',width:"40%" }}
                        onClick={()=>{this.props.history.push("/chargeMoney")}}
                    >
                        充值
                    </Button>
                    <WhiteSpace />
                    <WhiteSpace />
                    <Button
                        type="ghost" inline style={{ marginRight: '4px' ,width:"40%"}}
                        onClick={()=>{this.props.history.push("/withDraw")}}
                    >
                        提现
                    </Button>
                    <WhiteSpace />
                    <WhiteSpace />
                    <WhiteSpace />
                    <a style={{ display: 'block', marginTop: 40, marginBottom: 20, color: '#f8a83f',fontSize:'16px' }}
                       onClick={
                           ()=>{this.props.history.push("/walletRecord")}
                       }>
                        点此查看充值提现明细
                    </a>
                </div>
            </div>
        );
    }
}
